# -*- coding:utf-8 -*-
#! python3

from facecat import *

gPaint = FCPaint() #创建绘图对象
gPaint.defaultUIStyle = "dark"

#消息循环
def WndProc(hwnd,msg,wParam,lParam):
	return WndProcDefault(gPaint,hwnd,msg,wParam,lParam)

#创建窗体
createMainWindow(gPaint, "facecat-py", WndProc)

#创建列
#tree:树
def createTreeColumn(tree):
	treeColumn = FCTreeColumn()
	if tree.paint.defaultUIStyle == "dark":
		treeColumn.backColor = "rgb(0,0,0)"
		treeColumn.borderColor = "rgb(255,255,255)"
		treeColumn.textColor = "rgb(255,255,255)"
	elif tree.paint.defaultUIStyle == "light":
		treeColumn.backColor = "rgb(200,200,200)"
		treeColumn.borderColor = "rgb(0,0,0)"
		treeColumn.textColor = "rgb(0,0,0)"
	return treeColumn

#创建节点
#tree:树
def createTreeNode(tree):
	treeNode = FCTreeNode()
	if tree.paint.defaultUIStyle == "dark":
		treeNode.backColor = "rgb(0,0,0)"
		treeNode.borderColor = "rgb(255,255,255)"
		treeNode.textColor = "rgb(255,255,255)"
	elif tree.paint.defaultUIStyle == "light":
		treeNode.backColor = "rgb(255,255,255)"
		treeNode.borderColor = "rgb(0,0,0)"
		treeNode.textColor = "rgb(0,0,0)"
	return treeNode

#创建树
tree = FCTree()
#添加到框架中
addView(tree, gPaint)
#根据主题配色
if tree.paint.defaultUIStyle == "dark":
	tree.backColor = "rgb(0,0,0)"
	tree.borderColor = "rgb(255,255,255)"
	tree.textColor = "rgb(255,255,255)"
	tree.scrollBarColor = "rgb(100,100,100)"
elif tree.paint.defaultUIStyle == "light":
	tree.backColor = "rgb(255,255,255)"
	tree.borderColor = "rgb(0,0,0)"
	tree.textColor = "rgb(0,0,0)"
	tree.scrollBarColor = "rgb(200,200,200)"
#填充布局
tree.dock = "fill"
#隐藏列头
tree.headerHeight = 0
#显示复选框
tree.showCheckBox = True

#创建列
column = createTreeColumn(tree)
column.width = 500
tree.columns.append(column)
       
#创建根节点
rootNode = createTreeNode(tree)
rootNode.value = "证监会行业类"
appendTreeNode(tree, rootNode, None)

#创建子节点
node1 = createTreeNode(tree)
node1.value = "农、林、牧、渔业"
appendTreeNode(tree, node1, rootNode)

#创建孙节点
strs1 = []
strs1.append("农业")
strs1.append("林业")
strs1.append("畜牧业")
strs1.append("渔业")
strs1.append("农、林、牧、渔服务业")
for i in range(0, len(strs1)):
	subNode1 = createTreeNode(tree)
	subNode1.value = strs1[i]
	appendTreeNode(tree, subNode1, node1)

#创建子节点
node2 = createTreeNode(tree)
node2.value = "采矿业"
appendTreeNode(tree, node2, rootNode)

#创建孙节点
strs2 = []
strs2.append("煤炭开采和洗选业")
strs2.append("石油和天然气开采业")
strs2.append("黑色金属矿采选业")
strs2.append("有色金属矿采选业")
strs2.append("非金属矿采选业")
strs2.append("开采辅助活动")
for i in range(0, len(strs2)):
	subNode2 = createTreeNode(tree)
	subNode2.value = strs2[i]
	appendTreeNode(tree, subNode2, node2)

#创建子节点
node3 = createTreeNode(tree)
node3.value = "制造业"
appendTreeNode(tree, node3, rootNode)

#创建孙节点
strs3 = []
strs3.append("农副食品加工业")
strs3.append("食品制造业")
strs3.append("酒、饮料和精制茶制造业")
strs3.append("纺织业")
strs3.append("纺织服装、服饰业")
strs3.append("皮革、毛皮、羽毛及其制品和制鞋业")
strs3.append("木材加工和木、竹、藤、棕、草制品业")
strs3.append("家具制造业")
strs3.append("造纸和纸制品业")
strs3.append("印刷和记录媒介复制业")
strs3.append("文教、工美、体育和娱乐用品制造业")
strs3.append("石油加工、炼焦和核燃料加工业")
strs3.append("化学原料及化学制品制造业")
strs3.append("医药制造业")
strs3.append("化学纤维制造业")
strs3.append("橡胶和塑料制品业")
strs3.append("非金属矿物制品业")
strs3.append("黑色金属冶炼和压延加工业")
strs3.append("有色金属冶炼和压延加工业")
strs3.append("金属制品业")
strs3.append("通用设备制造业")
strs3.append("专用设备制造业")
strs3.append("汽车制造业")
strs3.append("铁路、船舶、航空航天和其他运输设备制造业")
strs3.append("电气机械和器材制造业")
strs3.append("计算机、通信和其他电子设备制造业")
strs3.append("仪器仪表制造业")
strs3.append("其他制造业")
strs3.append("废弃资源综合利用业")
for i in range(0, len(strs3)):
	subNode3 = createTreeNode(tree)
	subNode3.value = strs3[i]
	appendTreeNode(tree, subNode3, node3)

updateViewDefault(gPaint.views)
showWindow(gPaint)